<?php

	print_r(get_available());

	function get_available() {
		$con = mysqli_connect("localhost", "discovery_user", "hallo1", "mm_discovery");

		if(mysqli_connect_errno()) {
			echo "Kan niet verbinden: " . mysqli_connect_error();
		}

		$query = "SELECT machine, filename FROM available";
		$result = mysqli_query($con, $query);

		$entries = array();

		while($row = mysqli_fetch_array($result)) {

			$film1 = new filmpje();
			$film1->machine = $row['machine'];
			$film1->filename =  $row['filename'];

			array_push($entries, $film1);
		}

		mysqli_close($con);
		return json_encode($entries);
	}


	class filmpje
	{
		public $machine;
		public $filename; 
	}

?>